// Module: strategy (with packed arrays)
// Description: Top module that instantiates bbo_track, fv_calc and order_send.

module strategy #(
    parameter int NUM_CONTRACTS = 3
) (
    input  logic                         clk_net,
    input  logic                         rst_n,

    input  logic [NUM_CONTRACTS-1:0][31:0] bbo_bidprice,
    input  logic [NUM_CONTRACTS-1:0][31:0] bbo_askprice,
    input  logic [NUM_CONTRACTS-1:0][7:0]  bbo_bidvolume,
    input  logic [NUM_CONTRACTS-1:0][7:0]  bbo_askvolume,
    input  logic [NUM_CONTRACTS-1:0]       bbo_changed,
    input  logic [NUM_CONTRACTS-1:0][31:0] rels,

    output logic [NUM_CONTRACTS-1:0]       send_order_vld,
    output logic [NUM_CONTRACTS-1:0][31:0] send_order_price,
    output logic [NUM_CONTRACTS-1:0]       send_order_buy
);
    logic [NUM_CONTRACTS-1:0][31:0] current_bidprice, current_askprice;
    logic [NUM_CONTRACTS-1:0][7:0]  current_bidvolume, current_askvolume;
    logic                           fv_recalc_trigger;
    logic [NUM_CONTRACTS-1:0][31:0] fv_all;

    bbo_track #(.NUM_CONTRACTS(NUM_CONTRACTS)) u_bbo (
        .clk_net(clk_net), .rst_n(rst_n),
        .bbo_bidprice(bbo_bidprice),
        .bbo_askprice(bbo_askprice),
        .bbo_bidvolume(bbo_bidvolume),
        .bbo_askvolume(bbo_askvolume),
        .bbo_changed(bbo_changed),
        .current_bidprice(current_bidprice),
        .current_askprice(current_askprice),
        .current_bidvolume(current_bidvolume),
        .current_askvolume(current_askvolume),
        .fv_recalc_trigger(fv_recalc_trigger)
    );

    fv_calc #(.NUM_CONTRACTS(NUM_CONTRACTS)) u_fv (
        .clk_net(clk_net), .rst_n(rst_n),
        .royal_gala_bidprice(current_bidprice[0]),
        .royal_gala_askprice(current_askprice[0]),
        .royal_gala_bidvolume(current_bidvolume[0]),
        .royal_gala_askvolume(current_askvolume[0]),
        .rels(rels),
        .fv_recalc_trigger(fv_recalc_trigger),
        .fv_all(fv_all)
    );

    order_send #(.NUM_CONTRACTS(NUM_CONTRACTS)) u_order (
        .clk_net(clk_net),
        .rst_n(rst_n),
        .fv_all(fv_all),
        .bbo_bidprice(current_bidprice),
        .bbo_askprice(current_askprice),
        .bbo_changed(bbo_changed),
        .send_order_vld(send_order_vld),
        .send_order_price(send_order_price),
        .send_order_buy(send_order_buy)
    );

endmodule
